{extends file="../home.html"}
{block name="title"}{$head_title}{/block}
{block name="css"}
<!-- <link rel="stylesheet" style="text/css" href="__PUBLIC__/Css/front/user_glb.css?version={$version}"> -->

<style type="text/css">
    
</style>
{/block}
{block name="content"}
<form>
<div class="service_header">
    <i class="icon icon_back_default3x" style="top:.7rem"></i>
    <span>返回</span>
    <p>{$title}</p>
    <!-- <a href="javascript:;" class="icon icon_search3x"></a> -->
</div>z
<ul class="visit_from">
    <li class="clearfix">
        <label for="yin" class="fl">众创园区</label>
        <input type="text" id="yin" name="incubator_name" value="" placeholder="请输入众创园区名">
    </li>
    <li class="clearfix">
        <label for="name" class="fl">公司/项目名称</label>
        <input type="text" id="name" name="company_name" value="" placeholder="请输入公司/项目名称">
    </li>
    <li class="clearfix">
        <label for="date" class="fl">预约时间</label>
        <input type="date" id="date" name="order_time" value="" placeholder="请选择预约时间">
        <i class="fr icon icon_enter_default3x"></i>
    </li>
    <li class="clearfix">
        <label for="name_ren" class="fl">联系人姓名</label>
        <input type="text" id="name_ren" name="contacts" value="" placeholder="请输入联系人姓名">
    </li>
    <li class="clearfix">
        <label for="tell" class="fl">联系人电话</label>
        <input type="number" id="tell" name="contact_number" value="" placeholder="请输入联系人电话">
    </li>
    <li class="clearfix">
        <label for="number" class="fl">工位数量</label>
        <input type="number" id="station_num" name="station_num" value="" placeholder="请输入工位数量">
        <i class="fr icon icon_enter_default3x"></i>
    </li>
    <li class="clearfix">
        <label for="number" class="fl">工位类型</label>
        <select name="station_type" id="number">
            <option value="0">请选择工位类型</option>
        </select>
        <i class="fr icon icon_enter_default3x"></i>
    </li>
</ul>

<h6 class="bei">公司项目简介</h6>
<textarea name="user_remarks" placeholder="请输入公司项目简介" class="bei_txt"></textarea>
    <input type="hidden" value="order" name="opt">
    <input type="hidden" value="{$incubator_id}" name="incubator_id">
    <input type="hidden" value="{$type}" name="type">
{if $type==2}
<h6 class="bei">上传商业计划书</h6>
<div class="up_img clearfix">
    <div class="up_img_box fl">
        <a href="javascript:;" class="add icon fl icon_upload_default3x" title="上传一张新的图片" id="add_upload"></a>
        <input type="hidden" name="prospectus_url" class="img_url" id="img_url" />
    </div>
    <div class="preview fl clearfix img_html"></div>
</div>
{/if}
</form>
<a href="javascript:;" class="submit_btn">提交</a>
{/block}
{block name="js"}
<script>
    var incubator_id={$incubator_id}
</script>
{literal}
<!-- <script type="text/javascript" src="__PUBLIC__/Js/front/iscroll.js"></script> -->
<script type="text/javascript" src="/Public/Js/front/front_js/ajaxupload.3.5.js"></script>
        <script type="text/javascript">
                /*$(window).load(function() {
                });*/
            $(function()
            {
                $(".service_header i,.service_header span").on("click",function()
                {
                    history.go(-1);
                });
                $(".submit_btn").on("click",function()
                {
                    if($("#yin").val()=='')
                    {
                        layer.open({
                            content: '请输入预约园区',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#name").val()=='')
                    {
                        layer.open({
                            content: '请输入公司/项目名称',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#name_ren").val()=='')
                    {
                        layer.open({
                            content: '请输入预约人姓名',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    if($("#tell").val()=='')
                    {
                        layer.open({
                            content: '请输入联系人电话',
                            title: false,
                            btn: ['确定'],
                        });
                        return;
                    }
                    $.ajax({
                        type: 'POST',
                        url: '/FrontIncubator/order_zhongchuang' ,
                        data: $('form').serialize(),
                        dataType:'json',
                        success:function(data) {
                            console.log(data)
                            if(data.code == 1 ){
                                alert(data.msg);
                                location.href ="/FrontIncubator/zhongchuang_detail/incubator_id/"+incubator_id;
                            }else{
                                alert(data.msg);
                            }
                        }

                    })
                });
                $("body").on("click",".del_img",function(){
                    if($(this).parents(".preview").find('img').length==1){
                        $(this).parents(".img_html").siblings('.img_url').val('');      
                    }
                    $(this).parent(".img_box").remove();
                })
                // 上传图片
                new AjaxUpload("#add_upload", {
                action: "/Front/uploadHandler",
                name: "upfile",
                responseType: "json",
                onSubmit: function(){
                        //alert('正在上传');
                        //preview处的图片改为loading图片
                        $('.preview').show();
                        if($("#add_upload").siblings('.preview').find('img').length>=10){
                            alert("最多上传10张图片");
                            return false;
                        }
                    },
                    onChange: function(file, extension){
                        if (extension && /^(jpg|png|jpeg|gif)$/.test(extension)) {
                            return true;
                        }
                        else {
                            alert('暂不支持该图片格式！');
                            return false;
                        }
                    },
                    onComplete: function(file, response){
                    //  console.log(response);
                        if (response.status === 0) {
                            alert(response.msg);
                        }
                        else if (response.status === 1) {
                            var html;
                            html='<div class=" fl img_box"><img class="pic-preview" src="'+response.img_url+'"/><div class="del_img"></div></div>';
                            $('.preview').append(html);
                            // $("#add_upload").siblings('.preview').show();
                            $("#img_url").val(1);
                        }
                    }
                });
            });
        </script>
{/literal}
{/block}